home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Games / Arashi 1.1.1 / source code / Game Source / jam src / STShots.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-17  |  3.3 KB  |  169 lines  |  [TEXT/KAHL]

  1. /*/
  2.      Project Arashi: STShots.c
  3.      Major release: Version 1.1d2, 9/5/95
  4.  
  5.      Last modification: Thursday, December 17, 1992, 11:15
  6.      Created: Thursday, March 23, 1989, 20:25
  7.  
  8.      Copyright © 1989-1992, Juri Munkki
  9. /*/
  10.  
  11. #include "VA.h"
  12. #include "STORM.h"
  13.  
  14. Shot    shots[MAXSHOTS];    /*    Shot data structure is defined in STORM.h    */
  15. int        shotcount=0;
  16.  
  17. extern    Player    Hero;
  18.  
  19. /*
  20. >>    Produce a nice little explosion at (lane,level). These are
  21. >>    just simple pyrotechnics and as such do not really affect
  22. >>    any real shots.
  23. */
  24. void    ExplodeShot(lane,level)
  25. register    int        lane,level;
  26. {
  27.     register    int        x,y;
  28.  
  29.     x=ww.xc[lane][level];
  30.     y=ww.yc[lane][level];
  31.  
  32.     level=3 - (level << 2)/(DEPTH+1);    
  33.     VAExplosion(x,y,level,VA.color);
  34. }
  35. /*
  36. >>    A shot consists of five "spots". One in
  37. >>    the center and four around it placed symmetrically.
  38. >>    This routine draws a shot at (lane,level).
  39. */
  40. void    DrawShot(lane,level)
  41. register    int        lane,level;
  42. {
  43.     register    int        dx,dy,x,y;
  44.     static        int        shotrotation;
  45.  
  46.     shotrotation+=7;
  47.     if(shotrotation>=ANGLES) shotrotation-=ANGLES;
  48.     dx= ((ww.unitlen[level]>>3)*Cosins[shotrotation])>>8;
  49.     dy= ((ww.unitlen[level]>>3)*Sins[shotrotation])>>8;
  50.  
  51.     x=ww.xc[lane][level];
  52.     y=ww.yc[lane][level];
  53.  
  54.     VA.color=ThisLevel.shColor[4];
  55.     VASpot(x+dx,y+dy);
  56.  
  57.     if(level<DEPTH/3)
  58.     {
  59.         VA.color=ThisLevel.shColor[3];
  60.         VASpot(x-dx,y-dy);
  61.         VA.color=ThisLevel.shColor[2];
  62.         VASpot(x+dy,y-dx);
  63.         VA.color=ThisLevel.shColor[1];
  64.         VASpot(x-dy,y+dx);
  65.     }
  66.     VA.color=ThisLevel.shColor[0];
  67.     VASpot(x,y);
  68. }
  69. /*
  70. >>    To fire a bullet, call AddShot for that lane.
  71. >>    This routine returns -1, if a shot was available
  72. >>    and false, if none was fired.
  73. */
  74. int        AddShot(lane)
  75. int        lane;
  76. {
  77.     if(shotcount<MAXSHOTS)
  78.     {    shots[shotcount].lane=lane;
  79.         shots[shotcount].level=0;
  80.         shotcount++;
  81.         return -1;
  82.     }
  83.     else
  84.         return 0;
  85. }
  86. /*
  87. >>    This routine performs a hit test for your object.
  88. >>    When your object is near the center of a lane, call
  89. >>    this routine to determine if you were hit. -1 is
  90. >>    returned, if you were hit. The shot is removed from
  91. >>    the list and an explosion is displayed where the shot
  92. >>    was when it hit.
  93. */
  94. int        ShotHitTest(lane,level)
  95. register    int        lane,level;
  96. {
  97.     register    int        i;
  98.     register    Shot    *sp;
  99.     
  100.     if(Hero.superzapping)
  101.     {    if(Hero.superzapping==2)    /*    Single enemy zap.    */
  102.             Hero.superzapping=0;
  103.         return -2;                    /* mz */
  104.     }
  105.     
  106.     sp=shots;
  107.     for(i=0;i<shotcount;i++)
  108.     {    if(sp->lane==lane)
  109.         {    if(level <= sp->level)
  110.             if(level+4 >= sp->level)
  111.             {    ExplodeShot(lane,level);
  112.                 *sp=shots[--shotcount];
  113.                 return -1;
  114.             }
  115.         }
  116.         sp++;
  117.     }
  118.     return 0;
  119. }
  120. /*
  121. >>    UpdateShots moves the shots down one step and then refreshes
  122. >>    the display.
  123. */
  124. void    UpdateShots()
  125. {
  126.     register    int        i;
  127.     register    int        bottomlevel;
  128.     register    Shot    *shp;
  129.     
  130.     shp=shots;
  131.     
  132.     if(Hero.flydepth)
  133.     {    bottomlevel=DEPTH-Hero.flydepth;
  134.         for(i=0;i<shotcount;i++)
  135.         {    if(shp->level>=bottomlevel)
  136.             {    *shp=shots[--shotcount];
  137.                 i--;
  138.             }
  139.             else
  140.             {    if(!VA.Late && shp->level)    DrawShot(shp->lane,shp->level);
  141.                 shp->level+= ThisLevel.shSpeed;
  142.                 if(shp->level>bottomlevel)    shp->level=bottomlevel;
  143.                 shp++;
  144.             }
  145.         }
  146.     
  147.     }
  148.     else
  149.     {    for(i=0;i<shotcount;i++)
  150.         {    if(shp->level>=DEPTH)
  151.             {    *shp=shots[--shotcount];
  152.                 i--;
  153.             }
  154.             else
  155.             {    if(!VA.Late && shp->level)    DrawShot(shp->lane,shp->level);
  156.                 shp->level+= ThisLevel.shSpeed;
  157.                 if(shp->level>DEPTH)    shp->level=DEPTH;
  158.                 shp++;
  159.             }
  160.         }
  161.     }
  162. }
  163. /*
  164. >>    Start out with no shots fired.
  165. */
  166. void    InitShots()
  167. {
  168.     shotcount=0;
  169. }